package com.example.linktop.listviewdemo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private List<String> data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //数组
        data = new ArrayList<>();


        for (int i = 0; i < 100; i++) {

            data.add(Integer.toString(i));

        }


        ListView list = (ListView) findViewById(R.id.lv);

        list.setAdapter(new MyAdaper());




    }

    private class MyAdaper extends BaseAdapter {

        @Override
        public int getCount() {
            return 7;
        }


        @Override
        public Object getItem(int i) {
            return null;
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {

            View tv;

            //装换xml为对象
            if (view != null) {
                tv = view;
            } else  {

                tv = android.view.View.inflate(getApplicationContext(), R.layout.item,null);

            }


            return tv;


        }
    }


}
